//
//  TabebalViewHeader.m
//  HQJFacilitator
//
//  Created by mymac on 16/9/21.
//  Copyright © 2016年 Fujian first time iot technology investment co., LTD. All rights reserved.
//

#import "TabebalViewHeader.h"


@implementation TabebalViewHeader

-(instancetype)initWithFrame:(CGRect)frame {
    self =[super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [ManagerEngine getColor:@"00ccb8"];
        
        [self initializeUI];
        
        
       
        
//        [self settext];
    }
    
    
    return self;
}

-(UIActivityIndicatorView *)testActivityIndicator {
    
    if (!_testActivityIndicator) {
        _testActivityIndicator = [[UIActivityIndicatorView alloc]initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite];
        _testActivityIndicator.center = self.center;//只能设置中心，不能设置大小
        //        [testActivityIndicator setFrame = CGRectMack(100, 100, 100, 100)];//不建议这样设置，因为UIActivityIndicatorView是不能改变大小只能改变位置，这样设置得到的结果是控件的中心在（100，100）上，而不是和其他控件的frame一样左上角在（100， 100）长为100，宽为100.
        [self addSubview:_testActivityIndicator];
        _testActivityIndicator.color = [UIColor whiteColor]; // 改变圈圈的颜色为红色； iOS5引入
//        [_testActivityIndicator stopAnimating]; // 结束旋转
        [_testActivityIndicator setHidesWhenStopped:YES]; //当旋转结束时隐藏
        
    }
    
    return _testActivityIndicator;
}

-(UIView *)maskView {
    
    if (!_maskView) {
        _maskView  = [[UIView alloc]init];
        _maskView.backgroundColor = [UIColor blackColor];
        _maskView.alpha = 0.3;
        [self addSubview:_maskView];
    
    }
    
    return _maskView;
}

-(UIImageView *)headerImageView {
    if (!_headerImageView) {
        _headerImageView = [[UIImageView alloc]init];
        _headerImageView.image = [UIImage imageNamed:@"defaultHeader"];
        _headerImageView.layer.cornerRadius = 30;
        _headerImageView.layer.masksToBounds = YES;
        _headerImageView.userInteractionEnabled = YES;

        [self addSubview:_headerImageView];
        

    }
    
    return _headerImageView;
}
-(UILabel *)titleLabel {
    if (!_titleLabel) {
        _titleLabel = [[UILabel alloc]init];
        _titleLabel.font = [UIFont systemFontOfSize:18 weight:10];
        _titleLabel.textColor = [UIColor whiteColor];
//        _titleLabel.text = @"张子萱";
        [self addSubview:_titleLabel];
    }
    
    
    
    return _titleLabel;
}

-(UILabel *)numerLabel {
    
    if(!_numerLabel) {
        _numerLabel = [[UILabel alloc]init];
        _numerLabel.font = [UIFont systemFontOfSize:12];
        _numerLabel.textColor = [UIColor whiteColor];
//        _numerLabel.text = @"1383838438";
        [self addSubview:_numerLabel];
        
    }
    
    
    
    return _numerLabel;
}
-(UILabel *)bonusLabel {
    if (!_bonusLabel) {
        _bonusLabel = [[UILabel alloc]init];
        _bonusLabel.font =[UIFont systemFontOfSize:12];
        _bonusLabel.textColor = [UIColor whiteColor];
        
        [self addSubview:_bonusLabel];
    }
    
    
    return _bonusLabel;
}
-(void)initializeUI{
    
    
   
    
    
    self.headerImageView.sd_layout.
    leftSpaceToView(self,10).
    topSpaceToView(self,self.frame.size.height-30-30-60).
    heightIs(60).
    widthIs(60);
 
    
    
    self.titleLabel.sd_layout.
    leftSpaceToView(self.headerImageView,10).
    topEqualToView(self.headerImageView).
    heightIs(20).
    widthIs(WIDTH-100);
    
    self.numerLabel.sd_layout.
    leftEqualToView(self.titleLabel).
    topSpaceToView(self.titleLabel,0).
    heightIs(20).
    widthIs(WIDTH-100);
    self.bonusLabel.sd_layout.
    leftEqualToView(self.titleLabel).
    topSpaceToView(self.numerLabel,0).
    heightIs(20).
    widthIs(WIDTH-100);
    
     self.maskView.sd_layout.leftSpaceToView(self,0).topSpaceToView(self,self.frame.size.height-30).heightIs(30).widthIs(self.frame.size.width);
    
    
    [self.testActivityIndicator startAnimating ];
}

/********************************************************************/
/***************第一个线上崩溃BUG，调用空 block(已解决)*******************/
/********************************************************************/



@end
